package demo;
//多态能够减少代码的if-else的使用，并且可扩展能力强，但多态的运行效率低
class Shape{
    public void draw(){
        System.out.println("画图形");
    }
}
class Rect extends Shape{
    @Override
    public void draw() {
        System.out.println("矩形");
    }
}
class Circle extends Shape{
    @Override
    public void draw() {
        System.out.println("圆形");
    }
}
public class Test {
    public static void main(String[] args) {
        Shape[]shape={new Rect(),new Circle()};
        for (Shape shapes:shape) {
            shapes.draw();
        }
    }

}
